// 墙canvas子类
import canvasAbstract from './canvasAbstract';
import config from '../config';
import wallModel from '../model/wall';

export default new (class wall extends canvasAbstract implements ICanvas{
  name = 'wall';
  num(): number {
    return config.wall.num;
  };
  model(): ModelInterface {
    return wallModel;
  };
  render() {
    this.createModel();
    super.renderModel();
    this.createBossWall();
  };
  createBossWall() {
    const cw = config.canvas.width;
    const ch = config.canvas.hieght;
    const mw = config.model.width;
    const mh = config.model.height;
    const pos = [
      { x: cw / 2 - mw * 2, y: ch - mh },
      { x: cw / 2 - mw * 2, y: ch - mh * 2},
      { x: cw / 2 - mw * 2, y: ch - mh * 3},
      { x: cw / 2 - mw, y: ch - mh * 3},
      { x: cw / 2, y: ch - mh * 3},
      { x: cw / 2 + mw, y: ch - mh * 3},
      { x: cw / 2 + 2 * mw, y: ch - mh * 3},
      { x: cw / 2 + 2 * mw, y: ch - mh * 2},
      { x: cw / 2 + 2 * mw, y: ch - mh},
    ];
    pos.forEach(position => {
      const model = this.model();
      const instance = new model(position.x, position.y);
      this.modelist.push(instance);
    });
  }
})('wall');